package cn.dyw.simpletest;

import android.content.Context;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.widget.Toast;

/**
 * Created by dyw770 on 17-5-18.
 */

public class MyDatabaseHelper extends SQLiteOpenHelper {

    private Context context;

    private static final String CREATE_TABLE = "create table data(" +
            "id integer primary key autoincrement," +
            "name text," +
            "dataNum double," +
            "healthy text," +
            "time timestamp)";

    public MyDatabaseHelper(Context context, String name, SQLiteDatabase.CursorFactory factory, int version) {
        super(context, name, factory, version);
        this.context = context;
    }

    @Override
    public void onCreate(SQLiteDatabase db) {
        db.execSQL(CREATE_TABLE);
        Toast.makeText(context, "数据库创建成功", Toast.LENGTH_SHORT);
    }

    @Override
    public void onUpgrade(SQLiteDatabase db, int oldVersion, int newVersion) {

    }
}
